home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / C3DMFViewer / Sources / C3DMFViewerDoc.cp < prev    next >
Encoding:
Text File  |  1995-12-04  |  1.6 KB  |  66 lines  |  [TEXT/CWIE]

  1. //    C3DMFViewerDoc.cp
  2. //
  3. //    A PowerPlant application for viewing QuickDraw3D Metafiles
  4. //
  5. //    by James Jennings
  6. //    Started November 12, 1995
  7. //
  8.  
  9. #include "C3DMFViewerDoc.h"
  10.  
  11. const ResIDT    WIND_ViewerDoc        = 128;
  12.  
  13. C3DMFViewerDoc::C3DMFViewerDoc(
  14.     LCommander *inSuper, FSSpec *inFileSpec)
  15.         : LSingleDoc(inSuper)
  16. {
  17.                                     // Create window for our document
  18.     mWindow = LWindow::CreateWindow(WIND_ViewerDoc, this);
  19.     
  20.                                     // Specify that the text view should
  21.                                     // be the Target when the Window
  22.                                     // is activated
  23.     m3DMFPane = (C3DMFViewerPane*) mWindow->FindPaneByID(PaneID_Q3Viewer);
  24.     mWindow->SetLatentSub(m3DMFPane);// assign sub-commander
  25.     
  26.     if (inFileSpec == nil) {
  27. //        NameNewDoc();                // Set name of untitled window
  28.         
  29.     } else {
  30.         OpenFile(*inFileSpec);        // Display contents of file in window
  31.     }
  32. }
  33.  
  34. // ---------------------------------------------------------------------------
  35. //        • OpenFile
  36. // ---------------------------------------------------------------------------
  37. //    Open a new document for the specified File
  38.  
  39. void
  40. C3DMFViewerDoc::OpenFile( FSSpec    &inFileSpec)
  41. {
  42.         // Create a new File object, read the entire File contents,
  43.         // put the contents into the text view, and set the Window
  44.         // title to the name of the File.
  45.         
  46.     try {
  47.         mFile = new LFile(inFileSpec);
  48.         mFile->OpenDataFork(fsRdPerm);
  49.         
  50.         C3DMFViewerPane *thePane = (C3DMFViewerPane *)
  51.                     mWindow->FindPaneByID(PaneID_Q3Viewer);
  52.         ThrowIfNil_(thePane);
  53.         thePane->UseFile(mFile->GetDataForkRefNum());
  54.         
  55.         mWindow->SetDescriptor(inFileSpec.name);
  56.         mIsSpecified = true;
  57.     }
  58.     
  59.     catch(ExceptionCode inErr) {
  60.         delete this;
  61.         Throw_(inErr);
  62.     
  63.     }
  64. }
  65.  
  66.